package com.xy.edumap.util.page;

import java.util.ArrayList;
import java.util.List;

public class PageModel<T> {

	private int size;// 每页显示的条�?

	private int currentPage;// 当前�?

	private int sumCount;// 总条�?

	private int sumPage;// 总页�?

	private int first = 1;// 首页

	private int up;// 上一�?

	private int down;// 下一�?

	private int last;// 尾页

	private List<T> list = new ArrayList<T>();// 数据

	/**
	 * 
	 * 构�?方法
	 * 
	 * 创建对象的时候，给必要属性赋值�?
	 * 
	 * @return
	 */
	public PageModel(int size) {
		this.size = size;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {

		this.currentPage = currentPage;

		// 设置当前页的时�?，计算出上一页�?下一�?
		this.up = this.currentPage - 1 <= 1 ? 1 : this.currentPage - 1;

		this.down = this.currentPage + 1 >= sumPage ? sumPage : this.currentPage + 1;
	}

	public int getSumCount() {
		return sumCount;
	}

	public void setSumCount(int sumCount) {
		this.sumCount = sumCount;

		// 自动计算出�?的页�?
		this.sumPage = (int) Math.ceil(sumCount / (float) size);
		// 设置尾页
		this.last = this.sumPage;
	}

	public int getSumPage() {
		return sumPage;
	}

	public int getFirst() {
		return first;
	}

	public int getUp() {
		return up;
	}

	public void setUp(int up) {
		this.up = up;
	}

	public int getDown() {
		return down;
	}

	public void setDown(int down) {
		this.down = down;
	}

	public int getLast() {
		return last;
	}

	public void setLast(int last) {
		this.last = last;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

}
